package main;

public class Stack {

	// stack element
	private class Node {
		Object data;
		Node next;
	}

	// stack top
	Node top = null;

	// push item
	public void push(Object newData) {
		Node t = new Node();
		t.data = newData;
		if (top != null)
			t.next = top;
		top = t;
	}

	// pops an element from the top of the stack and returns it's data
	public Object pop() {
		if (top != null) {
			Object returnData = top.data;
			top = top.next;
			return returnData;
		} else
			return null;
	}

	// tells if the stack is empty
	public boolean empty() {
		return top == null;
	}

}
